package info.gridworld.actor;

import info.gridworld.grid.Location;

public class DancingBug extends Bug {
	
//    private int steps;
    private int turnIndex; // 当前turns的数组下标
    private int[] turns;  

    /**
     * Constructs a box bug that traces a square of a given side length
     * @param length the side length
     */
    public DancingBug(int[] turns)
    {
    	turnIndex = 0;
    	this.turns = turns;
    }

    /**
     * Moves to the next location of the square.
     */
    public void act()
    {
		this.setDirection(getDirection() + turns[turnIndex]
				* Location.HALF_RIGHT);
		
		move();
		turnIndex = (turnIndex + 1) % turns.length;
    }

}
